package com.rd.student.ruanjian.class4.zhangrui.day8_2.AnimalTest2;

abstract class Animal {
    private String name;

    public Animal(String name) {
        this.name=name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public abstract void voice();
    public abstract void enjoy();
}
//-------------------------------------
class Cat extends Animal {
 private String eyesColor;

    public Cat(String name, String eyesColor) {
        super(name);
        this.eyesColor = eyesColor;
    }

    public String getEyesColor() {
        return eyesColor;
    }

    public void setEyesColor(String eyesColor) {
        this.eyesColor = eyesColor;
    }

    @Override
    public void voice() {
        System.out.println(getName()+"喵喵喵");
    }

    @Override
    public void enjoy() {
        System.out.println(getName()+"快乐的跳");
    }
}
//-------------------------------------
 class Dog extends Animal {
private String furColor;

    public Dog(String name, String furColor) {
        super(name);
        this.furColor = furColor;
    }

    public String getFurColor() {
        return furColor;
    }

    public void setFurColor(String furColor) {
        this.furColor = furColor;
    }

    @Override
    public void voice() {
        System.out.println(getName()+"汪汪汪");
    }

    @Override
    public void enjoy() {
        System.out.println(getName()+"快乐的跑跳");
    }
}
//----------------------------------------
class Lady{
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Animal getPet() {
        return pet;
    }

    public void setPet(Animal pet) {
        this.pet = pet;
    }

    Animal pet;

    public Lady(String name, Animal pet) {
        this.name = name;
        this.pet = pet;
    }
    public void myPetEnjoy(){
        pet.enjoy();
    }
}

public class Test{
    public static void main(String[] args) {
        Animal a1=new Cat("小猫","蓝色");
        Lady lady1=new Lady("王女士",a1);
        System.out.print(lady1.getName()+"的"+a1.getName());
        lady1.myPetEnjoy();
        System.out.println();
        Animal a2=new Dog("小狗","黄色");
        Lady lady2=new Lady("张女士",a2);
        lady2.myPetEnjoy();
    }
}